#include "bucketsort.h"
vector<double> bucketsort(vector<double> &data) {
  priority_queue<double> sortedBucket;
  map<int, priority_queue<double>> buck;
  vector<double> res;
  for (auto e : data) {
    int index = static_cast<int>(10 * e);
    if (buck.count(index)) {
      buck[index].push(-e);
    } else {
      priority_queue<double, vector<double>> buckSort;
      buckSort.push(-e);
      buck.insert(make_pair(index, buckSort));
    }
  }
  for (auto buckIndex : buck) {
    auto e = buckIndex.second;
    while (!e.empty()) {
      res.push_back(-e.top());
      e.pop();
    }
  }
  return res;
}
